package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.common.RedisConst;
import com.itheima.health.dto.SubmitDTO;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Member;
import com.itheima.health.pojo.Order;
import com.itheima.health.pojo.OrderSetting;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.MemberService;
import com.itheima.health.service.OrderService;
import com.itheima.health.service.SetMealService;
import com.itheima.health.vo.OrderMemberSetmealVO;
import com.itheima.health.vo.OrderSubmitParam;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * 预约控制器
 */
@RestController
@RequestMapping("/mobile/order")
@Slf4j
@Api(tags = "手机端订单接口")
public class MobileOrderController {

    @Autowired
    private OrderService orderService;


    @GetMapping("/findById")
    public Result findById(Integer id){
        OrderMemberSetmealVO orderMemberSetmealVO = orderService.findById(id);
        return new Result(true,MessageConst.QUERY_ORDER_SUCCESS,orderMemberSetmealVO);
    }


    /**
     * 体检预约提交
     * @param submitDTO
     * @return
     */
    @PostMapping("/submit")
    public Result submit(@RequestBody SubmitDTO submitDTO) throws ParseException {
        log.info("预约提交");
        Order submitVO = orderService.submit(submitDTO);
        return new Result(true,MessageConst.ORDER_SUCCESS,submitVO);
    }


}
